﻿using System;
using SIOsystem.Model.OperatorDataSetTableAdapters;

namespace SIOsystem.Control
{
    class LoginClass
    {
        static public bool login(string uname, string pwd)
        {
            try
            {
                using (OperatorTableAdapter db = new OperatorTableAdapter())
                {
                    long autoID = db.Login(uname, pwd);
                    if (autoID > 0)
                    {
                        return true;
                    }
                    else
                    {
                        return false;
                    }
                }
            }
            catch (Exception ex)
            {
                throw new Exception("登录出错", ex);
            }
        }

        static public long getOID(string uname, string pwd)
        {
            try
            {
                using (OperatorTableAdapter db = new OperatorTableAdapter())
                {
                    long autoID = (long)db.GetOID(uname, pwd);
                    if (autoID > 0)
                    {
                        return autoID;
                    }
                    else
                    {
                        return -1;
                    }
                }
            }
            catch (Exception ex)
            {
                throw new Exception("登录出错", ex);
            }
        }
    }
}
